from django.contrib import admin

from app01 import models

# class The_number_of_clicks_admin(admin.ModelAdmin):
#     list_display = ['province_name', 'number', 'updatetime']
#     search_fields = ['province_name', 'number', ]
#
#
# admin.site.register(models.The_number_of_clicks, The_number_of_clicks_admin)
#
#
# class source_ip_admin(admin.ModelAdmin):
#     list_display = ['province_name', 'number', 'updatetime']
#     search_fields = ['province_name', 'number', ]
#     list_filter = ['province_name', 'number', 'updatetime']
#
#
# admin.site.register(models.source_ip, source_ip_admin)
#
#
# class Business_daily_traffic_admin(admin.ModelAdmin):
#     list_display = list(models.Business_daily_traffic.objects.all()[0].__dict__.keys())
#     list_display.remove('_state')
#     print(list_display)
#
#
# admin.site.register(models.Business_daily_traffic, Business_daily_traffic_admin)
# admin.site.register(models.real)
# admin.site.register(models.userpro)
# admin.site.register(models.Commodity_categories)
# admin.site.register(models.Commodity_subclass)
# admin.site.register(models.City_trading_volume)
# admin.site.register(models.subclass)
# admin.site.register(models.categories)
# admin.site.register(models.uv_real_time)
# admin.site.register(models.user_num)
# admin.site.register(models.zcpvuv)
# admin.site.register(models.jia_subclass)
# admin.site.register(models.Jiaywpv)
# print(models.Commodity_categories.objects.all().__dict__)


table_list = [
    'The_number_of_clicks', 'source_ip', 'Business_daily_traffic', 'real', 'City_trading_volume', 'subclass',
    'uv_real_time', 'user_num', 'zcpvuv', 'jia_subclass', 'Jiaywpv', 'Commodity_categories',
    'Commodity_subclass', 'userpro', 'business_real_time_access', 'provinces_rmb', 'categories',
    'guojia', 'city', 'qu'
]
demo = ''
for i in table_list:
    demo += '''
try:
    class %s_admin(admin.ModelAdmin):
        list_display = list(models.%s.objects.all()[0].__dict__.keys())
        for li in list_display:
            if "_id"   in li or "id"   in li:
                list_display.remove(li)
        list_display.remove('_state')
    admin.site.register(models.%s, %s_admin)
except Exception as e:
    admin.site.register(models.%s, )
    print(e,)
    ''' % (i, i, i, i, i)
# print(demo)
exec(demo)
